﻿using System;
using System.Web.UI.WebControls;
using DMS.BaseClass;
using DMS.Business.Modules.Organization;
using DMS.Business.Utility;

namespace DMS.Web.Modules.SystemManagement.Organization
{
    public partial class AddRoleMember : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.GetParams();
            if (!IsPostBack)
            {
                lb_title.Text = "请选择成员";
                if (!string.IsNullOrEmpty(Request.QueryString["title"]))
                    lb_title.Text = Request.QueryString["title"];
                string selectorMode = Request["selectorMode"];
                if (!String.IsNullOrEmpty(selectorMode))
                {
                    if(selectorMode.Equals("org")){
                        ClientHelper.Instance.RenderScript(Page, "", "javascript:showTagOnly('orgTag');");
                    }
                }
            }
        }

        private void GetParams()
        {
            if (!string.IsNullOrEmpty(Request["mode"]))
            {
                ListModeTypes mode = (ListModeTypes)Enum.Parse(typeof(ListModeTypes), Request["mode"].ToString());
                this.userList.Mode = mode;
            }

            User user = SystemContext.Current.LoginUser;
            if (user != null && user.Dept != null)
            {
                Department dept = user.Dept;
            }
        }

        protected void DeptTree_NodeClick(object sender, EventArgs e)
        {
            TreeNode node = this.deptTree.SelectedItem;
            if (node != null && !string.IsNullOrEmpty(node.Value))
            {
                this.userList.ContextDeptID = node.Value;
                this.userList.InitDataList();
            }
        }
    }
}